#! /usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = "Mosson"
import os
import django
from celery import Celery

# 在task中要调用django，进行日志处理
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'luffyapi.settings.dev')
django.setup()
# 1 创建 celery 主程序
app = Celery()

# 2 加载配置
app.config_from_object("mycelery.config")

# 3 注册任务
app.autodiscover_tasks(["mycelery.sms", "mycelery.email", "mycelery.order"])

# 启动celery
# celery -A myceler.main worker --loglevel=info


"""
如果有定时任务，需要先启动定时器，然后在启动celery
启动定时器【一定记得配置时区】
celery -A mycelery.main beat
启动celery
celery -A myceler.main worker --loglevel=info

"""
